package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Gcypaper;
import com.ruoyi.system.service.IGcypaperService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 论文管理3Controller
 * 
 * @author ruoyi
 * @date 2024-12-01
 */
@Controller
@RequestMapping("/system/gcypaper")
public class GcypaperController extends BaseController {
    private String prefix = "system/gcypaper";

    @Autowired
    private IGcypaperService gcypaperService;

    @RequiresPermissions("system:gcypaper:view")
    @GetMapping()
    public String gcypaper() {
        return prefix + "/gcypaper";
    }

    /**
     * 查询论文管理3列表
     */
    @RequiresPermissions("system:gcypaper:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Gcypaper gcypaper) {
        startPage();
        List<Gcypaper> list = gcypaperService.selectGcypaperList(gcypaper);
        return getDataTable(list);
    }

    /**
     * 导出论文管理3列表
     */
    @RequiresPermissions("system:gcypaper:export")
    @Log(title = "论文管理3", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Gcypaper gcypaper) {
        List<Gcypaper> list = gcypaperService.selectGcypaperList(gcypaper);
        ExcelUtil<Gcypaper> util = new ExcelUtil<Gcypaper>(Gcypaper.class);
        return util.exportExcel(list, "论文管理3数据");
    }

    /**
     * 新增论文管理3
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存论文管理3
     */
    @RequiresPermissions("system:gcypaper:add")
    @Log(title = "论文管理3", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Gcypaper gcypaper) {
        return toAjax(gcypaperService.insertGcypaper(gcypaper));
    }

    /**
     * 修改论文管理3
     */
    @RequiresPermissions("system:gcypaper:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        Gcypaper gcypaper = gcypaperService.selectGcypaperById(id);
        mmap.put("gcypaper", gcypaper);
        return prefix + "/edit";
    }

    /**
     * 修改保存论文管理3
     */
    @RequiresPermissions("system:gcypaper:edit")
    @Log(title = "论文管理3", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Gcypaper gcypaper) {
        return toAjax(gcypaperService.updateGcypaper(gcypaper));
    }

    /**
     * 删除论文管理3
     */
    @RequiresPermissions("system:gcypaper:remove")
    @Log(title = "论文管理3", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(gcypaperService.deleteGcypaperByIds(ids));
    }

    /**
     * 根据关键词查询论文管理3列表
     */
    @RequiresPermissions("main:list")
    @PostMapping("/search")
    @ResponseBody
    public TableDataInfo search(@RequestParam("keyword") String keyword) {
        startPage();
        List<Gcypaper> list = gcypaperService.searchGcypaperByKeyword(keyword);
        return getDataTable(list);
    }
}
